package com.ztf.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

import java.util.ArrayList;

/**
 * @author  ztf
 * 2022年3月7日13:37:01
 * 对swagger进行配置
 * **/
@Configuration
public class Swagger3Config {

    @Bean
    public Docket createRestApi(){
        return new Docket(DocumentationType.OAS_30)
                .groupName("开发组001")
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.ztf.controller.one"))  // 指定扫描的包  常用方式
                .build()
                .apiInfo(createApiInfo());
    }

    /**
     * 配置swagger的ApiInfo bean
     * @return
     */
    @Bean
    public ApiInfo createApiInfo(){
        return new ApiInfo("ztf Swagger"
                ,"ztf Api Documentation"
                ,"1.0"
                ,"http://www.ztf.vip"
                ,new Contact("赵富", "http://www.ztf.vip", "caofeng2012@126.com")
                ,"Apache 2.0"
                ,"http://www.apache.org/licenses/LICENSE-2.0"
                ,new ArrayList());
    }


    /**
     * 配置swagger的Docket bean
     * @return
     */
    @Bean
    public Docket createRestApi2() {
        return new Docket(DocumentationType.OAS_30)
                .enable(true)// 指定swagger3.0版本
                .groupName("开发组002")
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.ztf.controller.two"))  // 指定扫描的包  常用方式
                .build()
                .apiInfo(createApiInfo2());

    }

    /**
     * 配置swagger的ApiInfo bean
     * @return
     */
    @Bean
    public ApiInfo createApiInfo2(){
        return new ApiInfo("ztf Swagger"
                ,"ztf Api Documentation"
                ,"3.0"
                ,"http://www.ztf.vip"
                ,new Contact("小赵", "http://www.ztf.vip", "caofeng2012@126.com")
                ,"Apache 2.0"
                ,"http://www.apache.org/licenses/LICENSE-2.0"
                ,new ArrayList());
    }

}
